<?php
namespace Home\Model;
use Think\Model;

/**
* 
*/
class RegionModel extends Model
{
	
	function get_region($region_id)
	{

        $field = array(
                'parent_id' => $region_id
                );
        if($region_id == 1)
        {
            $result = $this->field('region_id,region_name')->where($field)->order('region_id asc')->select();
        }
        else
        {
            $result = $this->field('region_id,region_name')->where($field)->order('region_id asc')->select();
            foreach($result as $k=>$v)
            {
                $result .='<option value="'.$v['region_id'].'">'.$v['region_name'].'</option>';
            }
        }
        
        return $result;
	}

    function get_area($parent_id)
    {
        if($parent_id > 0)
        {
            $field = array(
                'parent_id' => $parent_id
                );
            $result = $this->field('region_id,region_name')->where($field)->order('region_id asc')->select();

            return $result;
        }
        
    }
}